par(mfrow=c(1, 2))
data<-read.csv('data/习题数据（基于R，EXCEL格式）/csv/E2_3.csv')
data
# 设置时间序列变量
rain<-ts(data$rain, frequency = 12, start=c(1945, 1))
# 绘制时序图
plot(rain, type="o", pch=5, col='#39CBB4', main="时序图", xlab="year", ylab="percent")

# 绘制自相关图并输出自相关系数
acf(rain, lag.max=24)$acf
acf_values <- acf(rain, lag.max = 24, plot = FALSE)$acf[-1]
print(round(acf_values, 3))

# 纯随机性检验
for( k in 1:3) print(Box.test(rain, lag=6*k, type="Ljung-Box"))

